package com.mzj.saas.mservice.lifePay.controller;

import com.mzj.saas.commons.ResultBean;
import com.mzj.saas.mservice.bill.vo.RentBillPaymentVo;
import com.mzj.saas.mservice.lifePay.service.LifePayService;
import com.mzj.saas.mservice.lifePay.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 生活缴费
 */

@Controller
@RequestMapping("/lifePay")
public class LifePayController {
    @Autowired
    private LifePayService lifePayService;

    /**
     * 我的缴费-我的缴费项列表
     */
    @GetMapping("/myPayPage")
    @ResponseBody
    public ResultBean<Object> myPayPage(@RequestHeader String accessToken) {

        return lifePayService.myPayPage(accessToken);
    }

    /**
     * 我的缴费-关联房屋所有缴费单列表
     */
    @GetMapping("/relatedHousesPayPage")
    @ResponseBody
    public ResultBean<Object> relatedHousesPayPage(@RequestHeader String accessToken, String houseId, Integer type) {
        return lifePayService.relatedHousesPayPage(accessToken, houseId, type);
    }

    /**
     * 我的缴费-、xx费用类型，所有账单列表
     */
    @GetMapping("/allBillsPage")
    @ResponseBody
    public ResultBean<Object> allBillsPage(@RequestHeader String accessToken) {

        return lifePayService.allBillsPage(accessToken);
    }

    /**
     * 新增缴费-房屋信息搜索
     */
    @GetMapping("/houseInformationSearch")
    @ResponseBody
    public ResultBean<Object> houseInformationSearch(@RequestHeader String accessToken, RequestParameterVO vo) {

        return lifePayService.houseInformationSearch(accessToken, vo);
    }

    /**
     * 新增缴费-房屋ID信息搜索
     */
    @GetMapping("/houseIdSearch")
    @ResponseBody
    public ResultBean<Object> houseIdSearch(@RequestHeader String accessToken, RequestParameterVO vo) {

        return lifePayService.houseIdSearch(accessToken, vo);
    }

    /**
     * 新增缴费-房屋关联绑定
     */
    @PostMapping("/houseBind")
    @ResponseBody
    public ResultBean<Object> houseBind(@RequestHeader String accessToken, @RequestBody HousePaymentBindVO vo) {

        return lifePayService.houseBind(accessToken, vo);
    }

    /**
     * 新增缴费-绑定费用
     */
    @PostMapping("/livingBind")
    @ResponseBody
    public ResultBean<Object> livingBind(@RequestHeader String accessToken, @RequestBody LivingPaymentBindVO vo) {

        return lifePayService.livingBind(accessToken, vo);
    }

    /**
     * 缴费管理-列表
     */
    @GetMapping("/payManagementPage")
    @ResponseBody
    public ResultBean<Object> payManagementPage(@RequestHeader String accessToken,
                                                @RequestParam(defaultValue = "0") Integer pageNumber,
                                                @RequestParam(defaultValue = "10") Integer pageSize) {
        return lifePayService.payManagementPage(accessToken);
    }

    /**
     * 用户分组列表
     */
    @GetMapping("/findGroup")
    @ResponseBody
    public ResultBean<Object> findGroup(@RequestHeader String accessToken) {

        return lifePayService.findGroup(accessToken);
    }

    /**
     * 缴费管理-新增分组
     */
    @PostMapping("/addGroup")
    @ResponseBody
    public ResultBean<Object> addGroup(@RequestHeader String accessToken,
                                       @RequestBody LivingPaymentGroupVO vo) {
        return lifePayService.addGroup(accessToken, vo);
    }

    /**
     * 缴费管理-编辑分组
     */
    @PutMapping("/updateGroup")
    @ResponseBody
    public ResultBean<Object> updateGroup(@RequestHeader String accessToken,
                                          @RequestBody LivingPaymentGroupVO vo) {
        return lifePayService.updateGroup(accessToken, vo);
    }

    /**
     * 缴费管理-删除分组
     */
    @DeleteMapping("/deleteGroup")
    @ResponseBody
    public ResultBean<Object> deleteGroup(@RequestHeader String accessToken,
                                          @RequestParam Long id) {
        return lifePayService.deleteGroup(accessToken, id);
    }

    /**
     * 缴费管理-编辑缴费
     */
    @PutMapping("/updatePay")
    @ResponseBody
    public ResultBean<Object> updatePay(@RequestHeader String accessToken,
                                        @RequestBody PaymentBindRequest vo) {
        return lifePayService.updatePay(accessToken, vo);
    }

    /**
     * 缴费管理-删除缴费
     */
    @DeleteMapping("/deletePay")
    @ResponseBody
    public ResultBean<Object> deletePay(@RequestHeader String accessToken,
                                        @RequestBody PaymentBindRequest vo) {
        return lifePayService.deletePay(accessToken, vo);
    }

    /**
     * 缴费记录-月份全类型统计
     */
    @GetMapping("/recordDetails")
    @ResponseBody
    public ResultBean<Object> recordDetails(@RequestHeader String accessToken, @RequestParam String statDate) {
        return lifePayService.recordDetails(accessToken, statDate);
    }

    /**
     * 缴费记录-某类型年份统计
     */
    @GetMapping("/recordDetailsByType")
    @ResponseBody
    public ResultBean<Object> recordDetailsByType(@RequestHeader String accessToken,
                                                  @RequestParam String statDate,
                                                  @RequestParam Integer type) {
        return lifePayService.recordDetailsByType(accessToken, statDate, type);
    }

    /**
     * 缴费记录-某类型年份统计详情
     */
    @GetMapping("/paymentDetails")
    @ResponseBody
    public ResultBean<Object> paymentDetails(@RequestHeader String accessToken,
                                             @RequestParam String statDate,
                                             @RequestParam Integer type) {
        return lifePayService.paymentDetails(accessToken, statDate, type);
    }

    /**
     * 返回城市下的小区
     */
    @GetMapping("/findCommunity")
    @ResponseBody
    public ResultBean<Object> findCommunity(@RequestHeader String accessToken, Long area) {

        return lifePayService.findCommunity(accessToken, area);
    }

    /**
     * 查询房号[物业房产和公租房]
     */
    @GetMapping("/findRoomNumber")
    @ResponseBody
    public ResultBean<List<String>> findRoomNumber(@RequestParam(value = "communityId") String communityId,
                                                   @RequestParam(value = "buildId") Long buildId,
                                                   @RequestParam(value = "unitId") Long unitId) {

        return lifePayService.findRoomNumber(communityId, buildId, unitId);
    }

    /**
     * 支付
     *
     * @param accessToken
     * @param vo
     * @return
     */
    @PostMapping("/payment")
    @ResponseBody
    public ResultBean<Map<String, Object>> payment(@RequestHeader String accessToken,
                                                   @RequestBody RentBillPaymentVo vo) {
        return lifePayService.payment(accessToken, vo);
    }


}
